//打印倒正金字塔
let n = parseInt(prompt('请输入层数：'))
if (n % 2 === 0) {
    n = n + 1;
    console.log(n);
}

//上层
function fn1() {
    let a = parseInt(n / 2)
    console.log(a);
    for (let i = 0; i < a; i++) {
        //左边
        for (let j = 0; j < i; j++) {
            document.write('<div class = "item">&nbsp;</div>')
        }
        // 右边
        for (let k = 0; k <= 2 * (a - i); k++) {
            document.write('<div class = "item">-</div>')
        }
        document.write('<br>')
    }
}

//下层
function fn2() {
    let b = parseInt(n / 2) + 1;
    console.log(b);
    for (let i = 0; i < b; i++) {
        // 左边
        for (let j = 0; j < b - i - 1; j++) {
            document.write('<div class = "item">&nbsp;</div>')
        }
        // 右边
        for (let k = 0; k < 2 * i + 1; k++) {
            document.write('<div class = "item">-</div>')
        }
        document.write('<br>')
    }
}


fn1()
fn2()